package com.fary.beans.factory.support;

import com.fary.beans.BeanMetadataAttributeAccessor;
import com.fary.util.Assert;

public class AutowireCandidateQualifier extends BeanMetadataAttributeAccessor {

	/**
	 * The name of the key used to store the value.
	 */
	public static final String VALUE_KEY = "value";

	private final String typeName;

	public AutowireCandidateQualifier(Class<?> type) {
		this(type.getName());
	}

	public AutowireCandidateQualifier(String typeName) {
		Assert.notNull(typeName, "Type name must not be null");
		this.typeName = typeName;
	}

	public AutowireCandidateQualifier(Class<?> type, Object value) {
		this(type.getName(), value);
	}

	public AutowireCandidateQualifier(String typeName, Object value) {
		Assert.notNull(typeName, "Type name must not be null");
		this.typeName = typeName;
		setAttribute(VALUE_KEY, value);
	}


	/**
	 * Retrieve the type name. This value will be the same as the
	 * type name provided to the constructor or the fully-qualified
	 * class name if a Class instance was provided to the constructor.
	 */
	public String getTypeName() {
		return this.typeName;
	}

}